import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    playlist: [],  // 播放列表
    currentId: '',  // 当前播放歌曲id
    playing: false, // 播放状态
  },
  getters: {
    song: state => state.playlist.find(i => i.id == state.currentId) || {}
  },
  mutations: {
    setPlaylist(state, arr) {
      state.playlist = arr;
    },
    setCurrentId(state, id) {
      state.currentId = id;
    },
    setPlaying(state, val) {
      state.playing = val;
    }
  },
  actions: {
  },
  modules: {
  }
})
